/******************************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Ltd.                       */
/*                                                                            */
/*  NAME      = db2_froca.h                                                  */
/*  NOTE      =                                                               */
/*  DATE      = 2015/03/19 by zhengxd                                         */
/******************************************************************************/
#ifndef _DB2_FROCA_H_
#define _DB2_FROCA_H_

#include "db2_comm.h"

#define DB2_SINGLE   1
#define DB2_DOUBLE   2

union int32_float_bits {
    int32_t int_bits;
    float float_bits;
};

union int64_double_bits {
    int64_t int_bits;
    double double_bits;
};

#define DRDA_TYPE_I4       0x02   //4-byte Integer
#define DRDA_TYPE_NI4      0x03   //Nullable 4-byte Integer
#define DRDA_TYPE_I2       0x04   //2-byte Integer
#define DRDA_TYPE_NI2      0x05   //Nullable 2-byte Integer
#define DRDA_TYPE_I1       0x06   //1-byte Integer
#define DRDA_TYPE_NI1      0x07   //Nullable 1-byte Integer
#define DRDA_TYPE_BF16     0x08   //16-byte Basic Floating Point
#define DRDA_TYPE_NBF16    0x09   //Nullable 16-byte Basic Floating Point
#define DRDA_TYPE_BF8      0x0A   //8-byte Basic Floating Point
#define DRDA_TYPE_NBF8     0x0B   //Nullable 8-byte Basic Floating Point
#define DRDA_TYPE_BF4      0x0C   //4-byte Basic Floating Point
#define DRDA_TYPE_NBF4     0x0D   //Nullable 4-byte Basic Floating Point
#define DRDA_TYPE_FD       0x0E   //Fixed Decimal
#define DRDA_TYPE_NFD      0x0F   //Nullable Fixed Decimal
#define DRDA_TYPE_ZD       0x10   //Zoned Decimal
#define DRDA_TYPE_NZD      0x11   //Nullable Zoned Decimal
#define DRDA_TYPE_N        0x12   //Numeric Character
#define DRDA_TYPE_NN       0x13   //Nullable Numeric Character
#define DRDA_TYPE_RSL      0x14   //Result Set Locator
#define DRDA_TYPE_NRSL     0x15   //Nullable Result Set Locator
#define DRDA_TYPE_I8       0x16   //Eight-byte Integer
#define DRDA_TYPE_NI8      0x17   //Nullable Eight-byte Integer
#define DRDA_TYPE_OBL      0x18   //Large Object Bytes Locator
#define DRDA_TYPE_NOBL     0x19   //Nullable Large Object Bytes Locator
#define DRDA_TYPE_OCL      0x1A   //Large Object Character Locator
#define DRDA_TYPE_NOCL     0x1B   //Nullable Large Object Character Locator
#define DRDA_TYPE_OCDL     0x1C   //Large Object Character DBCS Locator
#define DRDA_TYPE_NOCDL    0x1D   //Nullable Large Obj. Char. DBCS Locator
#define DRDA_TYPE_RI       0x1E   //Row Identifier
#define DRDA_TYPE_NRI      0x1F   //Nullable Row Identifier
#define DRDA_TYPE_D        0x20   //Date
#define DRDA_TYPE_ND       0x21   //Nullable Date
#define DRDA_TYPE_T        0x22   //Time
#define DRDA_TYPE_NT       0x23   //Nullable Time
#define DRDA_TYPE_TS       0x24   //Timestamp
#define DRDA_TYPE_NTS      0x25   //Nullable Timestamp
#define DRDA_TYPE_FB       0x26   //Fixed Bytes
#define DRDA_TYPE_NFB      0x27   //Nullable Fixed Bytes
#define DRDA_TYPE_VB       0x28   //Variable Bytes
#define DRDA_TYPE_NVB      0x29   //Nullable Variable Bytes
#define DRDA_TYPE_LVB      0x2A   //Long Variable Bytes
#define DRDA_TYPE_NLVB     0x2B   //Nullable Long Variable Bytes
#define DRDA_TYPE_NTB      0x2C   //Null-Terminated Bytes
#define DRDA_TYPE_NNTB     0x2D   //Nullable Null-Terminated Bytes
#define DRDA_TYPE_NTCS     0x2E   //Null-Terminated SBCS
#define DRDA_TYPE_NNTCS    0x2F   //Nullable Null-Terminated SBCS
#define DRDA_TYPE_FCS      0x30   //Fixed Character SBCS
#define DRDA_TYPE_NFCS     0x31   //Nullable Fixed Character SBCS
#define DRDA_TYPE_VCS      0x32   //Variable Character SBCS
#define DRDA_TYPE_NVCS     0x33   //Nullable Variable Character SBCS
#define DRDA_TYPE_LVCS     0x34   //Long Variable Character SBCS
#define DRDA_TYPE_NLVCS    0x35   //Nullable Long Variable Character SBCS
#define DRDA_TYPE_FCD      0x36   //Fixed Character DBCS
#define DRDA_TYPE_NFCD     0x37   //Nullable Fixed Character DBCS
#define DRDA_TYPE_VCD      0x38   //Variable Character DBCS
#define DRDA_TYPE_NVCD     0x39   //Nullable Variable Character DBCS
#define DRDA_TYPE_LVCD     0x3A   //Long Variable Character DBCS
#define DRDA_TYPE_NLVCD    0x3B   //Nullable Long Variable Character DBCS
#define DRDA_TYPE_FCM      0x3C   //Fixed Character Mixed
#define DRDA_TYPE_NFCM     0x3D   //Nullable Fixed Character Mixed
#define DRDA_TYPE_VCM      0x3E   //Variable Character Mixed
#define DRDA_TYPE_NVCM     0x3F   //Nullable Variable Character Mixed
#define DRDA_TYPE_LVCM     0x40   //Long Variable Character Mixed
#define DRDA_TYPE_NLVCM    0x41   //Nullable Long Variable Character Mixed
#define DRDA_TYPE_NTM      0x42   //Null-Terminated Mixed
#define DRDA_TYPE_NNTM     0x43   //Nullable Null-Terminated Mixed
#define DRDA_TYPE_PLB      0x44   //Pascal L String Bytes
#define DRDA_TYPE_NPLB     0x45   //Nullable Pascal L String Bytes
#define DRDA_TYPE_PLS      0x46   //Pascal L String SBCS
#define DRDA_TYPE_NPLS     0x47   //Nullable Pascal L String SBCS
#define DRDA_TYPE_PLM      0x48   //Pascal L String Mixed
#define DRDA_TYPE_NPLM     0x49   //Nullable Pascal L String Mixed
#define DRDA_TYPE_DLS      0x4C   //SBCS Datalink
#define DRDA_TYPE_NDLS     0x4D   //Nullable SBCS Datalink
#define DRDA_TYPE_DLM      0x4E   //Mixed-byte Datalink
#define DRDA_TYPE_NDLM     0x4F   //Nullable Mixed-byte Datalink
#define DRDA_TYPE_TSTZ     0xB6   //Timestamp with Time Zone
#define DRDA_TYPE_NTSTZ    0xB7   //Nullable Timestamp with Time Zone
#define DRDA_TYPE_CUR      0xB8   //Cursor Type
#define DRDA_TYPE_NCUR     0xB9   //Nullable Cursor Type
#define DRDA_TYPE_DFP      0xBA   //Decimal Floating Point
#define DRDA_TYPE_NDFP     0xBB   //Nullable Decimal Floating Point
#define DRDA_TYPE_XMLBIN   0xBC   //XML Binary
#define DRDA_TYPE_NXMLBIN  0xBD   //Nullable XML Binary
#define DRDA_TYPE_BL       0xBE   //Boolean
#define DRDA_TYPE_NBL      0xBF   //Nullable Boolean
#define DRDA_TYPE_FBIN     0xC0   //Fixed Binary
#define DRDA_TYPE_NFBIN    0xC1   //Nullable Fixed Binary
#define DRDA_TYPE_VBIN     0xC2   //Variable Binary
#define DRDA_TYPE_NVBIN    0xC3   //Nullable Variable Binary
#define DRDA_TYPE_XMLSIE   0xC4   //XML String Internal Encoding
#define DRDA_TYPE_NXMLSIE  0xC5   //Nullable XML String Internal Encoding
#define DRDA_TYPE_XMLSEE   0xC6   //XML String External Encoding
#define DRDA_TYPE_NXMLSEE  0xC7   //Nullable XML String External Encoding
#define DRDA_TYPE_OB       0xC8   //Large Object Bytes
#define DRDA_TYPE_NOB      0xC9   //Nullable Large Object Bytes
#define DRDA_TYPE_OCS      0xCA   //Large Object Character SBCS
#define DRDA_TYPE_NOCS     0xCB   //Nullable Large Object Character SBCS
#define DRDA_TYPE_OCD      0xCC   //Large Object Character DBCS
#define DRDA_TYPE_NOCD     0xCD   //Nullable Large Object Character DBCS
#define DRDA_TYPE_OCM      0xCE   //Large Object Character Mixed
#define DRDA_TYPE_NOCM     0xCF   //Nullable Large Object Character Mixed

int db2_parse_sqlcagrp(L7session_db2_private *p_st_private
                      , int i_whole_flg
                      , int *p_i_sqlcode
                      , char *p_sqlstate
                      , unsigned long *p_ul_effect_rows);

int db2_parse_sqldtagrp(Frbyte_Packet *p_st_data
                       , int i_whole_flg
                       , unsigned int ui_len
                       , Frlist_header *p_st_metadata);

int db2_parse_sqldata(Frbyte_Packet *p_st_data
                     , int i_whole_flg
                     , int i_typdef
                     , unsigned int ui_len
                     , Frlist_header *p_lst_metadata
                     , Frlist_header *p_lst_bind
                     , unsigned int *p_ui_ddm_left_len);

int db2_get_fetch_rows(L7session_db2_private *p_st_private
                     , int i_whole_flg
                     , Frlist_header *p_lst_metadata
                     , unsigned long *p_ul_rows
                     , Db2_req_cmd *p_st_cmd_cp);

int db2_get_fdodsc(Frbyte_Packet *p_st_data
                  , int i_whole_flg
                  , unsigned int ui_fdodsc_len
                  , Frlist_header *p_lst_metadata
                  , unsigned int *p_ui_ddm_left_len);
#endif
